package cn.thoughtworks.school.entities.vo;

import cn.thoughtworks.school.entities.Operation;
import cn.thoughtworks.school.entities.Program;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Builder;
import lombok.Data;

import java.util.Date;

@Data
@Builder
public class ProgramHistoryVo {
    private Long id;
    private Long programId;
    private String title;
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date operateTime;
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date startTime;
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date endTime;
    private String category;
    private String introduction;
    private Boolean studentLink;
    private Boolean tutorLink;
    private Boolean isReadOnly;
    private Boolean isExpired;
    private Boolean available;
    private String username;
    private Operation operation;

    public static ProgramHistoryVo build(Program program, String username) {
        return ProgramHistoryVo.builder()
            .title(program.getTitle())
            .id(program.getId())
            .programId(program.getProgramId())
            .operateTime(program.getOperateTime())
            .startTime(program.getStartTime())
            .endTime(program.getEndTime())
            .category(program.getCategory())
            .introduction(program.getIntroduction())
            .studentLink(program.getStudentLink())
            .tutorLink(program.getTutorLink())
            .isExpired(program.getIsExpired())
            .isReadOnly(program.getIsReadOnly())
            .available(program.getAvailable())
            .username(username)
            .operation(program.getOperation())
            .build();
    }
}
